package com.curluin.model;

import com.curluin.approximateShapes.ApproximateShape;
import com.curluin.approximateShapes.Contour;
import com.curluin.controll.Controller;
import com.curluin.math.MyVector;
import com.curluin.scene.Cube;
import com.curluin.scene.Node;
import com.curluin.scene.TriangleMesh;

public class Snow extends ModelObject implements Obstacle {

	private static final String LOG_TAG = "Snow";

	public Snow(MyVector position, int positionMode){
		super(position, ModelObject.CONSITENCY_HARD_AS_ICE);
		debugColor=TriangleMesh.SNOW_WHITE;		
		if(this.getClass().equals(Snow.class)) initialize(position, positionMode);
	}

	public Snow(TriangleMesh mesh, MyVector position,int positionMode, MyVector rotation){
		super(mesh, position, ModelObject.CONSITENCY_HARD_AS_ICE);
		debugColor=TriangleMesh.SNOW_WHITE;		
		if(this.getClass().equals(Snow.class)){ 
			initialize(position, positionMode);
			node.rotate(rotation, false);
			shape.rotateScanData(node.xyzRotationAngles, node.getCenter());
		}
	}

	@Override
	protected Node composeGraphics() {
		return new Cube(MyVector.makeVector3(0, 0, 0), 10, 10, 10, TriangleMesh.SNOW_WHITE);
	}

	@Override
	protected ApproximateShape initializeApproximateShape() {
		//		Rectangle r = new Rectangle(node);
		//		Ellipse r = new Ellipse(node);
		//		Log.w(LOG_TAG, "vertices: "+node.getVertices());
		Contour r = new Contour(20, node);
		//		Log.w(LOG_TAG, "vertices: "+node.getVertices());
		r.scan(Controller.getGridFieldWidth(), true);
		return r;
	}

	@Override
	public MyVector detailledCollisionCheck(ModelObject mo) {
		// detailled collision check
		if(mo.position.get(1)-mo.getSize().get(1)/2>this.position.get(1)+node.outerSize.get(1)/2) return null;
		if(mo.position.get(1)+mo.getSize().get(1)/2<this.position.get(1)-node.outerSize.get(1)/2) return null;
		return this.position;
	}	

}
